package com.bq.gametrade.http;


import com.alibaba.fastjson.TypeReference;
import com.bq.gametrade.bean.AliPay;
import com.bq.gametrade.bean.BankCardList;
import com.bq.gametrade.bean.BindGameAccount;
import com.bq.gametrade.bean.CancelledRecorded;
import com.bq.gametrade.bean.AddressBook;
import com.bq.gametrade.bean.FriendsList;
import com.bq.gametrade.bean.GamesAccountDetails;
import com.bq.gametrade.bean.GamesList;
import com.bq.gametrade.bean.HomeTradingBean;
import com.bq.gametrade.bean.Interconnected;
import com.bq.gametrade.bean.Announcement;
import com.bq.gametrade.bean.RechargeMoney;
import com.bq.gametrade.bean.RedEnvelopeList;
import com.bq.gametrade.bean.RedEnvelopeRecords;
import com.bq.gametrade.bean.ResponseBean;
import com.bq.gametrade.bean.TradingRecordsDetails;
import com.bq.gametrade.bean.TransferBill;
import com.bq.gametrade.bean.UpdateUserInfo;
import com.bq.gametrade.bean.TransferContacts;
import com.bq.gametrade.bean.UserInfo;
import com.bq.gametrade.bean.UserTradingRecord;
import com.bq.gametrade.bean.WeChatPay;
import com.bq.gametrade.bean.WithdrawalRecords;
import com.bq.gametrade.utils.ApplicationUtil;
import com.bq.gametrade.utils.BQLog;


/**
 * 功能：数据解析
 * <p>
 * Created by user on 2016/4/26.
 */
public class Parser {
    private static final String ParserError = "数据解析出错";


    /**
     * 登录：获取用户信息
     * @param json
     * @return
     */
    public static UserInfo getUserInfo(String json) {
        UserInfo result = new UserInfo();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<UserInfo>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;

    }
    /**
     * 登录：更新用户信息
     * @param json
     * @return
     */
    public static UpdateUserInfo updateUserInfo(String json) {
        UpdateUserInfo result = new UpdateUserInfo();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<UpdateUserInfo>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;

    }


    /**
     * 首页：交易列表
     * @param json
     * @return
     */
    public static HomeTradingBean getSellingList(String json) {
        HomeTradingBean result = new HomeTradingBean();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<HomeTradingBean>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：交易记录详情
     * @param json
     * @return
     */
    public static TradingRecordsDetails getTradingRecordsDetailsList(String json) {
        TradingRecordsDetails result = new TradingRecordsDetails();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<TradingRecordsDetails>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：游戏列表
     * @param json
     * @return
     */
    public static GamesList getGamesNameList(String json) {
        GamesList result = new GamesList();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<GamesList>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：转账联系人
     * @param json
     * @return
     */
    public static TransferContacts getTransferContactsList(String json) {
        TransferContacts result = new TransferContacts();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<TransferContacts>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 通讯录
     * @param json
     * @return
     */
    public static AddressBook getAddressBookList(String json) {
        AddressBook result = new AddressBook();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<AddressBook>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：我的朋友列表
     * @param json
     * @return
     */
    public static FriendsList getMyFriendList(String json) {
        FriendsList result = new FriendsList();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<FriendsList>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：转账账单
     * @param json
     * @return
     */
    public static TransferBill getTransferBillList(String json) {
        TransferBill result = new TransferBill();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<TransferBill>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }


    /**
     * 绑定游戏账号列表
     * @param json
     * @return
     */
    public static BindGameAccount getBindGameAccount(String json) {
        BindGameAccount result = new BindGameAccount();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<BindGameAccount>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 绑定银行卡列表
     * @parm json
     * @return
     */
    public static BankCardList getBindBankCardList(String json) {
        BankCardList result = new BankCardList();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<BankCardList>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 绑定银行卡列表
     * @parm json
     * @return
     */
    public static WithdrawalRecords getWithdrawalList(String json) {
        WithdrawalRecords result = new WithdrawalRecords();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<WithdrawalRecords>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }
    /**
    /**
     * 挂单记录
     * @pam json
     * @return
     */
    public static CancelledRecorded getCancelledRecordList(String json) {
        CancelledRecorded result = new CancelledRecorded();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<CancelledRecorded>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 互联明细
     * @pam json
     * @return
     */
    public static Interconnected getInterconnectedList(String json) {
        Interconnected result = new Interconnected();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<Interconnected>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 个人交易记录
     * @pam json
     * @return
     */
    public static UserTradingRecord getTradingrecordList(String json) {
        UserTradingRecord result = new UserTradingRecord();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<UserTradingRecord>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 充值金额列表
     * @pam json
     * @return
     */
    public static RechargeMoney getRechargeMoneyList(String json) {
        RechargeMoney result = new RechargeMoney();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<RechargeMoney>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：通用
     * @param json
     * @return
     */
    public static ResponseBean getResponseData(String json) {
        ResponseBean result = new ResponseBean();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<ResponseBean>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }
    /**
     * 首页：通用
     * @param json
     * @return
     */
    public static GamesAccountDetails getGameAccountDetaills(String json) {
        GamesAccountDetails result = new GamesAccountDetails();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<GamesAccountDetails>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：微信支付
     * @param json
     * @return
     */
    public static WeChatPay sendWeChatPay(String json) {
        WeChatPay result = new WeChatPay();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<WeChatPay>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 首页：微信支付
     * @param json
     * @return
     */
    public static AliPay sendAliPay(String json) {
        AliPay result = new AliPay();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<AliPay>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }
    /**
     * 首页：通用
     * @param json
     * @return
     */
    public static Announcement getAnnouncement(String json) {
        Announcement result = new Announcement();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<Announcement>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 红包列表
     * @parm json
     * @return
     */
    public static RedEnvelopeList getRedEnvolopeList(String json) {
        RedEnvelopeList result = new RedEnvelopeList();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<RedEnvelopeList>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }

    /**
     * 红包记录
     * @parm json
     * @return
     */
    public static RedEnvelopeRecords getRedEnvolopeRecords(String json) {
        RedEnvelopeRecords result = new RedEnvelopeRecords();

        try {
            result = ApplicationUtil.fromJson(json, new TypeReference<RedEnvelopeRecords>() {
            }.getType());
        } catch (Exception e) {
            BQLog.log("ParkNewsEntry", ParserError);
        }
        return result;
    }
}
